﻿using Microsoft.Extensions.Primitives;

namespace Acl.Messages;

/// <summary>
/// 订阅到的远程消息
/// </summary>
public interface IDistributionMessage<TData>
{
    /// <summary>
    /// 消息主题
    /// </summary>
    string Topic { get; }

    /// <summary>
    /// 回复的消息主题
    /// </summary>
    string? ReplyTo { get; }

    /// <summary>
    /// 负载数据的大小
    /// </summary>
    int Size { get; }

    /// <summary>
    /// 消息头
    /// </summary>
    IDictionary<string, StringValues>? Headers { get; }

    /// <summary>
    /// 负载数据
    /// </summary>
    TData? Data { get; }

    /// <summary>
    /// 回复消息
    /// </summary>
    /// <param name="data">回复的负载数据</param>
    /// <param name="opts">回复时参数选项</param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    ValueTask ReplyAsync<TReplyData>(TReplyData data, in DistributionPublishOptions? opts = default, CancellationToken cancellationToken = default);
}